package link.gpt.service.impl;

import link.gpt.dao.NewsCommentDao;
import link.gpt.pojo.NewsComment;
import link.gpt.pojo.NewsCommentExample;
import link.gpt.service.NewsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version V1.0A
 * @uthor gpt
 * @Project holiday_task
 * @Package link.gpt.service.impl
 * @Description: ${TODO}
 * @Date 2021/10/7 15:56
 */
@Service
public class NewsCommentServiceImpl implements NewsCommentService {


   @Autowired
   private NewsCommentDao newsCommentDao;

   @Override
   public List<NewsComment> findAllByNewsId(Integer newsId) {
      NewsCommentExample newsCommentExample = new NewsCommentExample();
      NewsCommentExample.Criteria criteria = newsCommentExample.createCriteria();
      criteria.andNewsIdEqualTo(newsId);
      return newsCommentDao.selectByExample(newsCommentExample);
   }

   @Override
   public int addComment(NewsComment newsComment) {
      return newsCommentDao.insertSelective(newsComment);
   }
}
